<template>
      <van-dropdown-menu class="dropdown">
      <van-dropdown-item v-model="value" :options="option" @change="price(value)" />
    </van-dropdown-menu>
</template>
<script>
import { categorybrandprolist } from '../../api/index'
export default {
  data() {
    return {
      value: 'a',
      option: [
        { text: '默认排序', value: 'a' },
        { text: '价格升序', value: 'b' },
        { text: '价格倒序', value: 'c' }
      ],
      goodsList: []
    }
  },
  methods: {
    price (value) {
      if (value === 'b') {
        console.log(this.goodsList)
        this.goodsList.sort(function (a, b) {
          return a.originprice - b.originprice
        })
      }
      if (value === 'c') {
        this.goodsList.sort(function (a, b) {
          return b.originprice - a.originprice
        })
      }
    }
  },
  mounted () {
    this.zhonglei = localStorage.getItem('zhonglei')
    this.paizi = this.$route.params.proid
    categorybrandprolist({
      count: 1,
      limitNum: 10,
      category: this.zhonglei,
      brand: this.paizi
    }).then(res => {
      this.goodsList = res.data.data
    })
  }

}
</script>
<style lang="scss" scoped>
</style>